function varargout = bandplot(x,y,mm)
%BANDPLOT plot with continuous confidence/error boundaries.
%
% varargout = bandplot(x,y,mm)
%
% input
%	x: variable on x axis
%	y: data for error band matrix (2 x length(x))
%		1st row for lower band
%		2nd row for upper band
%	mm: (optional) value for bottom point of y axis
% output (optinal)
%	varargout	
	

%   originally coded by
%   2002 - Michele Giugliano, PhD (http://www.giugliano.info) (Bern, Monday Nov 4th, 2002 - 19:02)
%    (bug-reports to michele@giugliano.info)
%   $Revision: 1.0 $  $Date: 2002/11/11 14:36:08 $
%                        
%  minor modification by
% Jay H. Hong, Dept of Economics
% University of Pennsylvania
% 3718 Locust Walk
% Philadelphia, PA 19104
% jayhwa@econ.upenn.edu


if (nargin<2)
 disp('ERROR: not enough input arguments!');
 return;
end % if

p = plot(x,y);    YLIM = get(gca,'YLim');    delete(p);
if (nargin==2)
 mm=min(YLIM);
end
a1 = area(x,y(2,:),mm); 
hold on;
set(a1,'LineStyle','none');     set(a1,'FaceColor',[0.8 0.8 0.8]);
a2 = area(x,y(1,:),mm-0.01); 
set(a2,'LineStyle','none');     set(a2,'FaceColor',[1 1 1]);
set(gca,'Layer','top');               
H = [a1; a2];

if (nargout>0) varargout{1} = H; end;
